/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Filippo
 */
@Entity
@Table(name = "component")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Component.findAll", query = "SELECT c FROM Component c"),
    @NamedQuery(name = "Component.findById", query = "SELECT c FROM Component c WHERE c.id = :id"),
    @NamedQuery(name = "Component.findByCategory", query = "SELECT c FROM Component c WHERE c.category = :category")})
public class Component implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Column(name = "Category")
    private String category;
    @JoinTable(name = "data_component", joinColumns = {
        @JoinColumn(name = "Id_Component", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "Id_DataFile", referencedColumnName = "ID")})
    @ManyToMany
    private Collection<DataFile> dataFileCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "component")
    private Collection<SystemActionOnComponent> systemActionOnComponentCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private CoolingSystem coolingSystem;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Disk disk;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private NetworkInterface networkInterface;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Rack rack;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private BusinessProcess businessProcess;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private ServiceInstance serviceInstance;
    @OneToMany(mappedBy = "idComponent")
    private Collection<Annotation> annotationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "component")
    private Collection<Thresholds> thresholdsCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private VirtualMachineInst virtualMachineInst;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private DiskArray diskArray;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "component")
    private Collection<ObservedComponent> observedComponentCollection;
    @OneToMany(mappedBy = "idComponent")
    private Collection<GpiKpiInstance> gpiKpiInstanceCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Activity activity;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Cpu cpu;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idComponent")
    private Collection<StoredValues> storedValuesCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Memory memory;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Isle isle;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "component")
    private Collection<VirtualMachineResources> virtualMachineResourcesCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Service service;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private CpuCore cpuCore;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Server server;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Storage storage;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "component")
    private Room room;

    public Component() {
    }

    public Component(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    @XmlTransient
    public Collection<DataFile> getDataFileCollection() {
        return dataFileCollection;
    }

    public void setDataFileCollection(Collection<DataFile> dataFileCollection) {
        this.dataFileCollection = dataFileCollection;
    }

    @XmlTransient
    public Collection<SystemActionOnComponent> getSystemActionOnComponentCollection() {
        return systemActionOnComponentCollection;
    }

    public void setSystemActionOnComponentCollection(Collection<SystemActionOnComponent> systemActionOnComponentCollection) {
        this.systemActionOnComponentCollection = systemActionOnComponentCollection;
    }

    @XmlTransient //added by Gigi
    public CoolingSystem getCoolingSystem() {
        return coolingSystem;
    }

    public void setCoolingSystem(CoolingSystem coolingSystem) {
        this.coolingSystem = coolingSystem;
    }

    @XmlTransient //added by Gigi
    public Disk getDisk() {
        return disk;
    }

    public void setDisk(Disk disk) {
        this.disk = disk;
    }

    @XmlTransient //added by Gigi
    public NetworkInterface getNetworkInterface() {
        return networkInterface;
    }

    public void setNetworkInterface(NetworkInterface networkInterface) {
        this.networkInterface = networkInterface;
    }

    @XmlTransient //added by Gigi
    public Rack getRack() {
        return rack;
    }

    public void setRack(Rack rack) {
        this.rack = rack;
    }

    @XmlTransient //added by Gigi
    public BusinessProcess getBusinessProcess() {
        return businessProcess;
    }

    public void setBusinessProcess(BusinessProcess businessProcess) {
        this.businessProcess = businessProcess;
    }

    @XmlTransient //added by Gigi
    public ServiceInstance getServiceInstance() {
        return serviceInstance;
    }

    public void setServiceInstance(ServiceInstance serviceInstance) {
        this.serviceInstance = serviceInstance;
    }

    @XmlTransient
    public Collection<Annotation> getAnnotationCollection() {
        return annotationCollection;
    }

    public void setAnnotationCollection(Collection<Annotation> annotationCollection) {
        this.annotationCollection = annotationCollection;
    }

    @XmlTransient
    public Collection<Thresholds> getThresholdsCollection() {
        return thresholdsCollection;
    }

    public void setThresholdsCollection(Collection<Thresholds> thresholdsCollection) {
        this.thresholdsCollection = thresholdsCollection;
    }

    public VirtualMachineInst getVirtualMachineInst() {
        return virtualMachineInst;
    }

    @XmlTransient //added by Gigi
    public void setVirtualMachineInst(VirtualMachineInst virtualMachineInst) {
        this.virtualMachineInst = virtualMachineInst;
    }

    public DiskArray getDiskArray() {
        return diskArray;
    }

    @XmlTransient //added by Gigi
    public void setDiskArray(DiskArray diskArray) {
        this.diskArray = diskArray;
    }

    @XmlTransient
    public Collection<ObservedComponent> getObservedComponentCollection() {
        return observedComponentCollection;
    }

    public void setObservedComponentCollection(Collection<ObservedComponent> observedComponentCollection) {
        this.observedComponentCollection = observedComponentCollection;
    }

    @XmlTransient
    public Collection<GpiKpiInstance> getGpiKpiInstanceCollection() {
        return gpiKpiInstanceCollection;
    }

    public void setGpiKpiInstanceCollection(Collection<GpiKpiInstance> gpiKpiInstanceCollection) {
        this.gpiKpiInstanceCollection = gpiKpiInstanceCollection;
    }

    @XmlTransient //added by Gigi
    public Activity getActivity() {
        return activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    @XmlTransient //added by Gigi
    public Cpu getCpu() {
        return cpu;
    }

    public void setCpu(Cpu cpu) {
        this.cpu = cpu;
    }

    @XmlTransient
    public Collection<StoredValues> getStoredValuesCollection() {
        return storedValuesCollection;
    }

    public void setStoredValuesCollection(Collection<StoredValues> storedValuesCollection) {
        this.storedValuesCollection = storedValuesCollection;
    }

    @XmlTransient //added by Gigi
    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }

    @XmlTransient //added by Gigi
    public Isle getIsle() {
        return isle;
    }

    public void setIsle(Isle isle) {
        this.isle = isle;
    }

    @XmlTransient
    public Collection<VirtualMachineResources> getVirtualMachineResourcesCollection() {
        return virtualMachineResourcesCollection;
    }

    public void setVirtualMachineResourcesCollection(Collection<VirtualMachineResources> virtualMachineResourcesCollection) {
        this.virtualMachineResourcesCollection = virtualMachineResourcesCollection;
    }

    @XmlTransient //added by Gigi
    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    @XmlTransient //added by Gigi
    public CpuCore getCpuCore() {
        return cpuCore;
    }

    public void setCpuCore(CpuCore cpuCore) {
        this.cpuCore = cpuCore;
    }

    @XmlTransient //added by Gigi
    public Server getServer() {
        return server;
    }

    public void setServer(Server server) {
        this.server = server;
    }

    @XmlTransient //added by Gigi
    public Storage getStorage() {
        return storage;
    }

    public void setStorage(Storage storage) {
        this.storage = storage;
    }

    @XmlTransient //added by Gigi
    public Room getRoom() {
        return room;
    }

    public void setRoom(Room room) {
        this.room = room;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Component)) {
            return false;
        }
        Component other = (Component) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.Component[ id=" + id + " ]";
    }
    
}
